<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="js/jquery-3.5.1.min.js"></script>
  <title>速卖通授权</title>
</head>
<style>
  body,
  html {
    padding: 0;
    margin: 0;
  }

  #mainpage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .h1 {
    color: #000000;
  }

</style>

<body>
  <div id="mainpage">
    <h1 class="h1" id="h1"></h1>
  </div>
</body>

<script>
  $(function () {
    var url = window.location.href;
    var querys = url.substring(url.indexOf('?') + 1).split('&');
    var result = [];
    for (var i = 0; i < querys.length; i++) {
      var temp = querys[i].split('=');
      if (temp.length < 2) {
        result[temp[0]] = '';
      } else {
        result[temp[0]] = temp[1];
      }
    }
    if (result.code && result.storeId) {
      $.ajax({
        url: "/dev-api/ae/auth/getAccessToken?code=" + result.code + '&storeId=' + result.storeId,
        dataType: "json",
        type: "get",
        async: '',
        data: {},
        success: function (res) {
          $('#h1').html(res.msg)
        },
        error: function (res) {
        }
      });
    } else {
      $('#h1').html('授权失败')
    }
  });
</script>

</html>
